package com.lzwk.tableSql.lhApp;

import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @Author: CC
 * @Date: 2022/2/22 20:51
 */
public class Cdc {
    public static void student(StreamTableEnvironment tableEnv) {
        String sql = "" +
                "CREATE TABLE lh_app_student " +
                "(" +
                "`id` INT," +
                "`account_id` INT," +
                "`division_activity_id` INT," +
                "`activity_term_id` INT," +
                "`student_no` INT," +
                "`term_class_id` INT," +
                "`rank` INT," +
                "`channel_id` INT," +
                "`state` STRING," +
                "`study_state` STRING," +
                "`sub_class_id` INT," +
                "`liveroom_id` INT," +
                "`remark` STRING," +
                "`class_name` STRING," +
                "`entrance_grade` STRING," +
                "`entrance_issue` STRING," +
                "`json_extend` STRING," +
                " PRIMARY KEY (`id`) NOT ENFORCED" +
                ")" +
                "" + "WITH (" +
                "           'connector' = 'mysql-cdc' " +
                "           ,'hostname' = '10.1.192.241' " +
                "           ,'port' = '3306' " +
                "           ,'username' = 'lihua_app' " +
                "           ,'password' = 'FGwC6pNLGkWV' " +
                "           ,'database-name' = 'lihua_app' " +
                "           ,'table-name' = 'student' " +
                "           ,'server-id' = '28500-28510' " +
                "           ,'server-time-zone' = 'Asia/Shanghai' " +
                "           ,'debezium.snapshot.locking.mode' = 'none' " +
                "        )";
        tableEnv.executeSql(sql);
    }
    public static void studentBase(StreamTableEnvironment tableEnv) {
        String sql = "" +
                "CREATE TABLE lh_app_student_base " +
                "(" +
                "`id` INT," +
                "`account_id` INT," +
                "`full_name` STRING," +
                "`nickname` STRING," +
                "`avatar` STRING," +
                "`age_range` STRING," +
                "`gender` INT," +
                "`country` STRING," +
                "`province` STRING," +
                "`city` STRING," +
                "`area` STRING," +
                "`address` STRING," +
                "`telephone` STRING," +
                "`career` STRING," +
                " PRIMARY KEY (`id`) NOT ENFORCED" +
                ")" +
                "" + "WITH (" +
                "           'connector' = 'mysql-cdc' " +
                "           ,'hostname' = '10.1.192.241' " +
                "           ,'port' = '3306' " +
                "           ,'username' = 'lihua_app' " +
                "           ,'password' = 'FGwC6pNLGkWV' " +
                "           ,'database-name' = 'lihua_app' " +
                "           ,'table-name' = 'student_base' " +
                "           ,'server-id' = '28511-28520' " +
                "           ,'server-time-zone' = 'Asia/Shanghai' " +
                "           ,'debezium.snapshot.locking.mode' = 'none' " +
                "        )";
        tableEnv.executeSql(sql);
    }

    public static void studentExtend(StreamTableEnvironment tableEnv) {
        String sql = "" +
                "CREATE TABLE lh_app_student_extend " +
                "(" +
                "`id` INT," +
                "`account_id` INT," +
                "`division_activity_id` INT," +
                "`activity_term_id` INT," +
                "`review_level` STRING," +
                "`last_level` STRING," +
                "`graduate_gift` STRING," +
                "`graduate_cert` STRING," +
                "`exam_sign_up_info` STRING," +
                "`exam_state` STRING," +
                "`cert_apply_state` STRING," +
                "`exam_sign_up_info` STRING," +
                "`outer_create_time` TIMESTAMP," +
                " PRIMARY KEY (`id`) NOT ENFORCED" +
                ")" +
                "" + "WITH (" +
                "           'connector' = 'mysql-cdc' " +
                "           ,'hostname' = '10.1.192.241' " +
                "           ,'port' = '3306' " +
                "           ,'username' = 'lihua_app' " +
                "           ,'password' = 'FGwC6pNLGkWV' " +
                "           ,'database-name' = 'lihua_app' " +
                "           ,'table-name' = 'student_extend' " +
                "           ,'server-id' = '28521-28530' " +
                "           ,'server-time-zone' = 'Asia/Shanghai' " +
                "           ,'debezium.snapshot.locking.mode' = 'none' " +
                "        )";
        tableEnv.executeSql(sql);
    }

    public static void studentSubClass(StreamTableEnvironment tableEnv) {
        String sql = "" +
                "CREATE TABLE lh_app_sub_class " +
                "(" +
                "`id` INT," +
                "`teacher_id` INT," +
                " PRIMARY KEY (`id`) NOT ENFORCED" +
                ")" +
                "" + "WITH (" +
                "           'connector' = 'mysql-cdc' " +
                "           ,'hostname' = '10.1.192.241' " +
                "           ,'port' = '3306' " +
                "           ,'username' = 'lihua_app' " +
                "           ,'password' = 'FGwC6pNLGkWV' " +
                "           ,'database-name' = 'lihua_app' " +
                "           ,'table-name' = 'sub_class' " +
                "           ,'server-id' = '28531-28540' " +
                "           ,'server-time-zone' = 'Asia/Shanghai' " +
                "           ,'debezium.snapshot.locking.mode' = 'none' " +
                "        )";
        tableEnv.executeSql(sql);
    }

    public static void teacher(StreamTableEnvironment tableEnv) {
        String sql = "" +
                "CREATE TABLE lh_app_sub_class " +
                "(" +
                "`id` INT," +
                "`account_id` INT," +
                "`name` STRING," +
                " PRIMARY KEY (`id`) NOT ENFORCED" +
                ")" +
                "" + "WITH (" +
                "           'connector' = 'mysql-cdc' " +
                "           ,'hostname' = '10.1.192.241' " +
                "           ,'port' = '3306' " +
                "           ,'username' = 'lihua_app' " +
                "           ,'password' = 'FGwC6pNLGkWV' " +
                "           ,'database-name' = 'lihua_app' " +
                "           ,'table-name' = 'teacher' " +
                "           ,'server-id' = '28541-28550' " +
                "           ,'server-time-zone' = 'Asia/Shanghai' " +
                "           ,'debezium.snapshot.locking.mode' = 'none' " +
                "        )";
        tableEnv.executeSql(sql);
    }
}
